<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
{% extends "terminal/base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %} {{title}} {% endblock %}

{% block navbar %}
<nav class="navbar navbar-inverse" style="margin-bottom: 0px; border-radius: 0px;">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">iMonitor Web Terminal</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li ><a id="terminalStatus"></a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li>
                </li>
            </ul>
        </div>
    </div>
</nav>
{% endblock %}

{% block page_content %}
<div class="container-fluid" style="padding-right: 0px; padding-left: 0px;">
    <div id="terminal-container"></div>
</div>
{% endblock %}

{% block scripts %}
<script src="{{ url_for('static', filename='js/TerminalEditor.js') }}"></script>
<script>
    options = {
        id: 'terminal-container',
        show_banner: true,
        data: {{server_id}},
        user: {{current_user.id}}
    }
    TerminalEditor.init(options);

    // 每1秒检查连接
    window.setInterval(function(){
        if (TerminalEditor.status() == 'false' || TerminalEditor.status() == false) {
            document.getElementById('terminalStatus').innerHTML = '无法连接';
        } else {
            document.getElementById('terminalStatus').innerHTML = '已连接';
        }
    }, 1000);
</script>
{% endblock %}
